/*
 *   This File is Part of CuteOgre Game Engine
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *	Copyright 2010 Alexandre Pires ( c.alexandre.pires@gmail.com )
 *  Created on: 2010/09/04
 */

#ifndef STYLEMANAGER_H_
#define STYLEMANAGER_H_

#include "IManager.h"
#include "Singleton.h"
#include "StyleSheet.h"
#include <QMap>

class StyleSheetManager : public IManager, public Singleton<StyleSheetManager> {

friend class GUIManager;

typedef QMap<QString, StyleSheet*> StyleSheetsMap;

private:
	bool mShutdown;
	StyleSheetsMap mStyleSheets;

protected:
	StyleSheetManager () : mShutdown(true) {

	}

public:
	~StyleSheetManager ();

	static StyleSheetManager* getSingletonPtr(void) {
		return ms_Singleton;
	}

	static StyleSheetManager& getSingleton(void) {
		assert( ms_Singleton );
		return (*ms_Singleton);
	}

	void init ();
	void shutdown ();

	void load ( const QString& rName );

	inline bool exists ( const QString& rName ) {
		return (mStyleSheets.find(rName) != mStyleSheets.end());
	}

	StyleSheet* getStyleSheet ( const QString& rName );

	inline static void loadStyleSheet ( const QString& rName ) {
		StyleSheetManager::getSingleton().load(rName);
	}

	inline static StyleSheet* styleSheet ( const QString& rName ) {
		return StyleSheetManager::getSingleton().getStyleSheet(rName);
	}

	inline static bool isLoaded ( const QString& rName ) {
		return StyleSheetManager::getSingleton().exists(rName);
	}
};

#endif /* STYLEMANAGER_H_ */
